package org.chen.model.repository;

import org.chen.model.domain.Menu;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @Author: 陈亮
 * @Date: 2019/3/24 17:33
 */
@Repository
public interface MenuRepository extends JpaRepository<Menu, Integer> {

    @Query(value = "SELECT m.id , m.parent_id , m.name , m.sort , m.href , m.target , m.icon , m.permission , m.del_flag,m.remarks FROM sys_role_menu rm JOIN sys_menu m ON m.id = rm.menu_id WHERE rm.role_id = ?1", nativeQuery = true)
    List<Menu> findByRoleId(Integer id);

}
